package com.portal.portal.config;

import javax.servlet.ServletContext;

import com.gaeig.base.ApplicationInjector;
import com.google.inject.Inject;
import com.portal.portal.config.service.DriverBasicInfoService;
import com.portal.portal.config.service.DriverPortalURLParseService;
import com.portal.portal.config.service.DriverRenderService;
import com.portal.portal.config.service.DriverSupportedModesService;
import com.portal.portal.config.service.DriverWindowStateService;
import com.portal.util.exception.PortalDriverConfigurationException;

public class DriverConfigurationServiceFacade {

  @Inject
  private DriverBasicInfoService driverBasicInfoService;
  @Inject
  private DriverPortalURLParseService driverPortalURLParseService;
  @Inject
  private DriverRenderService driverRenderService;
  @Inject
  private DriverSupportedModesService driverSupportedModesService;
  @Inject
  private DriverWindowStateService driverWindowStateService;

  private static DriverConfigurationServiceFacade facade;

  private DriverConfigurationServiceFacade() {
    ApplicationInjector.getInjector().injectMembers(this);
  }

  public static DriverConfigurationServiceFacade getInstance() {
    if(facade == null){
      facade = new DriverConfigurationServiceFacade();
    }
    return facade;
  }

  public DriverBasicInfoService getDriverBasicInfoService() {
    return driverBasicInfoService;
  }

  public DriverPortalURLParseService getDriverPortalURLParseService() {
    return driverPortalURLParseService;
  }

  public DriverRenderService getDriverRenderService() {
    return driverRenderService;
  }

  public DriverSupportedModesService getDriverSupportedModesService() {
    return driverSupportedModesService;
  }

  public DriverWindowStateService getDriverWindowStateService() {
    return driverWindowStateService;
  }

  public void destroy() throws PortalDriverConfigurationException {
    driverBasicInfoService.destroy();
    driverPortalURLParseService.destroy();
    driverRenderService.destroy();
    driverSupportedModesService.destroy();
    driverWindowStateService.destroy();
  }

  public void init(ServletContext servletContext) throws PortalDriverConfigurationException {
    driverBasicInfoService.init(servletContext);
    driverPortalURLParseService.init(servletContext);
    driverRenderService.init(servletContext);
    driverSupportedModesService.init(servletContext);
    driverWindowStateService.init(servletContext);
  }

  public void setDriverBasicInfoService(DriverBasicInfoService driverBasicInfoService) {
    this.driverBasicInfoService = driverBasicInfoService;
  }

  public void setDriverPortalURLParseService(DriverPortalURLParseService driverPortalURLParseService) {
    this.driverPortalURLParseService = driverPortalURLParseService;
  }

  public void setDriverRenderService(DriverRenderService driverRenderService) {
    this.driverRenderService = driverRenderService;
  }

  public void setDriverSupportedModesService(DriverSupportedModesService driverSupportedModesService) {
    this.driverSupportedModesService = driverSupportedModesService;
  }

  public void setDriverWindowStateService(DriverWindowStateService driverWindowStateService) {
    this.driverWindowStateService = driverWindowStateService;
  }

}
